package com.qfedu.api.coupon.fallback;

import com.qfedu.api.coupon.feign.CouponInfoFeignService;
import com.qfedu.common.core.common.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class CouponFeignFallbackFactory implements FallbackFactory<CouponInfoFeignService> {
    @Override
    public CouponInfoFeignService create(Throwable cause) {
        return new CouponInfoFeignService() {
            @Override
            public R distributeCoupon(Integer productType, Integer uid) {
                log.error(cause.getMessage());
                return R.fail("领取优惠券失败");
            }
        };
    }
}
